﻿//qt
#include <QApplication>
#include <QTranslator>
#include <QIcon>
#include <QDir>

//自定义
#include "cuserlogin.h"
//sdk
#include "./audio/high_level_api/include/IAgoraRtcEngine.h"
//#include "./audio/high_level_api/include/IAgoraRtcEngineEx.h"


bool loadGlobalStyle(const QString &path)
{
    QFile f(path);
    if (!f.open(QFile::ReadOnly | QFile::Text))
        return false;
    qApp->setStyleSheet(f.readAll());
    return true;
}


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setWindowIcon(QIcon(":/res/company.png"));

    //===============test============
    agora::rtc::RtcEngineContext RtcEngineContext;
    RtcEngineContext.appId = "aaa";
    //RtcEngineContext.eventHandler = this;

    // 创建 IRtcEngine 实例
    agora::rtc::IRtcEngine* RtcEngineProxy = ::createAgoraRtcEngine();
    // 初始化 IRtcEngine
    RtcEngineProxy->initialize(RtcEngineContext);


    // 启用视频模块
    RtcEngineProxy->enableVideo();
    // 设置频道媒体选项
    agora::rtc::ChannelMediaOptions options;
    // 自动订阅所有音频流
    options.autoSubscribeAudio = true;
    // 自动订阅所有视频流
    options.autoSubscribeVideo = true;
    // 发布摄像头采集的视频
    options.publishCameraTrack = true;
    // 发布麦克风采集的音频
    options.publishMicrophoneTrack = true;
    // 将频道场景设为直播
    options.channelProfile = agora::CHANNEL_PROFILE_TYPE::CHANNEL_PROFILE_LIVE_BROADCASTING;
    // 将用户角色设为主播或观众
    options.clientRoleType = agora::rtc::CLIENT_ROLE_TYPE::CLIENT_ROLE_AUDIENCE;
    // 加入频道
    RtcEngineProxy->joinChannel("32432", "grtetre", 0, options);
    //===========================

    //汉化
    QTranslator p ;
    p.load(":/res/qt_zh_CN.qm");
    a.installTranslator(&p);

    // 1. 先加载全局样式
    //QString path = QDir("D:/work/windows-vvclass/VVClass/res/themes").filePath("vvclass.qss");
    //loadGlobalStyle(path);   // 直接传绝对路径

    CUserLogin userlogin;
    userlogin.show();
    return a.exec();
}
